Globals in ControlMacros.carp

-->

macro

Macro

                        (--> :rest forms)
                    

threads the first form through the following ones, making it the last argument.

Example:

(--> 1
    (- 10)
    (/ 45)
) ; => 5

->

macro

Macro

                        (-> :rest forms)
                    

threads the first form through the following ones, making it the first argument.

Example:

(-> 1
    (- 10)
    (* 5)
) ; => -45

==> deprecated

macro

Macro

                        (==> :rest forms)
                    

deprecated in favor of -->.

=> deprecated

macro

Macro

                        (=> :rest forms)
                    

deprecated in favor of ->.

case

macro

Macro

                        (case form :rest branches)
                    

takes a form and a list of branches which are value and operation pairs. If a value matches (or any in a list of values preced by :or), the operation is executed. It takes a catch-all else branch that is executed if nothing matches.

Example:

(case (+ 10 1)
  10 (println* "nope")
  11 (println* "yup")
  (:or 12 13) (println* "multibranch, but nope")
  (println* "else branch")
)

comp

macro

Macro

                        (comp :rest fns)
                    

Composes the functions fns into one fn.

defn-do

macro

Macro

                        (defn-do name arguments :rest body)
                    

is a defn with an implicit do body.

doto

macro

Macro

                        (doto thing :rest expressions)
                    

Evaluates thing, then calls all of the functions on it and returns it. Useful for chaining mutating, imperative functions, and thus similar to ->. If you need thing to be passed as a ref into expressions functions, use doto-ref instead.

(let [x @"hi"]
  @(doto &x
    (string-set! 0 \o)
    (string-set! 1 \y)))

doto-ref

macro

Macro

                        (doto-ref thing :rest expressions)
                    

Evaluates thing, then calls all of the functions on it and returns it. Useful for chaining mutating, imperative functions, and thus similar to ->. If you need thing not to be passed as a ref into expressions functions, use doto instead.

(doto-ref @"hi"
  (string-set! 0 \o)
  (string-set! 1 \y))

forever-do

macro

Macro

                        (forever-do :rest forms)
                    

is a forever with an implicit do body.

ignore-do

macro

Macro

                        (ignore-do :rest forms)
                    

Wraps side-effecting forms in a do, ignoring all of their results. In other words, executes forms only for their side effects.

let-do

macro

Macro

                        (let-do bindings :rest forms)
                    

is a let with an implicit do body.

unless

macro

Macro

                        (unless condition form)
                    

is an if without a then branch.

until

macro

Macro

                        (until cnd body)
                    

Executes body until the condition cnd is true.

when

macro

Macro

                        (when condition form)
                    

is an if without an else branch.

while-do

macro

Macro

                        (while-do condition :rest forms)
                    

is a while with an implicit do body.